package net.spider.bttiantang;

import java.io.IOException;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.viva.entity.cms.Movie;

public class Main {
    private static final Logger log = LoggerFactory.getLogger(Main.class);

    public static void main(String[] args) throws IOException {
        Page page = new Page();
        int pageCount = page.getPageCount(page.baseUrl);
        String urlWithPageParamater = "";
        for (int i = pageCount; i > 0; i--) {
            // 这里可以用多线程去抓
            if (i != 1) {
                urlWithPageParamater = page.baseUrl + "?PageNo=" + i;
            } else {
                urlWithPageParamater = page.baseUrl;
            }
            List<Movie> movies = page.getMovieFormPage(urlWithPageParamater);
            System.out.println("-----------------------------------" + "第" + i + "页：共" + movies.size() + "条数据");
            // MyFileUtils.writeObjectToFile(movieFormIndexPage,
            // "ListOfMovies.q");
            for (int j = 0; j < movies.size(); j++) {
                MovieDetail d = new MovieDetail();
                Movie movie = d.getMovie(movies.get(j));
                System.out.println(movie);
            }
            break;
        }

        // List<Movie> movies = (List<Movie>)
        // MyFileUtils.readObjectFromFile("ListOfMovies.q");

    }
}
